#include "MultiThreadMainDlg.h"
#include "ui_MultiThreadMainDlg.h"

MultiThreadMainDlg::MultiThreadMainDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MultiThreadMainDlg), m_tcpClient(new MTTcpClient)
{
    ui->setupUi(this);

}

MultiThreadMainDlg::~MultiThreadMainDlg()
{
    delete ui;
}

void MultiThreadMainDlg::on_timeout()
{
    if (!m_tcpClient->isConnected()) {
        on_btnConnect_clicked();
    }
}

void MultiThreadMainDlg::on_btnConnect_clicked()
{
    QString ip = ui->lineEditIP->text();
    int port = ui->lineEditPort->text().toInt();

    m_tcpClient->connectToHost(ip, port);
}

void MultiThreadMainDlg::on_btnDisConnect_clicked()
{
    m_tcpClient->disconnect();
}


